import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
// Pinia 持久化插件
import { createUnistorage } from "pinia-plugin-unistorage"
export const useCounterStore = defineStore('counter', () => {
  // 定义 state
  const count = ref(0)

  // 定义 getters
  const double = computed(() => count.value * 2)

  // 定义 actions
  const increment = () => {
    count.value++
  }

  const decrement = () => {
    count.value--
  }

  // 千万不要忘记这里要 return
  return { count, double, increment, decrement }
}, {
  // @ts-ignore
  unistorage: {
    key:'cp-patient',
    paths:['countcount']
  }, // 开启后对 state 的数据读写都将持久化
},)